#ifndef unigame_ComponentHolder_h
#define unigame_ComponentHolder_h

#include "Component.h"
#include "config/Def.h"

namespace unigame
{
	class GameObject;
	class ComponentHolder
	{
	public:
		ComponentHolder(Component* com, GameObject* go):m_value(com), m_gameObject(go)
		{
			m_value->retain();
		}

		~ComponentHolder()
		{
			m_value->release();
		}

		Component* value()
		{
			return m_value;
		}
	
		void value(Component* com)
		{
			m_value = com;
		}

		GameObject* gameObject()
		{
			return m_gameObject;
		}

		int32u type()
		{
			if(m_value)
			{
				return m_value->type();
			}
			return E_NONT_CT;
		}

	private:
		Component* m_value;
		GameObject* m_gameObject;
	};
}

#endif